<template>
    <div id="AmentPortrait">
         <div class="masklayer">
            <div class='aportrait'>
                <h3>修改密码</h3>
                <!-- <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1539075667832&di=0aec402113b624f4847e9d2c7b4f335b&imgtype=0&src=http%3A%2F%2Fpic14.nipic.com%2F20110605%2F1369025_165540642000_2.jpg" alt=""> -->
                <input type="text" placeholder="修改用户名" v-model='name' value="">
                <!-- <input type="text" placeholder="请输入原密码"> -->
                <input type="password" placeholder="请输入新密码" v-model="newPwd">
                <input type="password" placeholder="请确认密码" v-model="cPwd">
                <div>
                    <el-button type="primary" plain class="btn" @click="markSure">确认修改</el-button>
                    <el-button type="primary" plain class="btn" @click="goback">返回</el-button>
                     <!-- <button @click="updata">显示</button>  -->
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    export default{
        data(){
            return {
                isShow:false,
                newPwd:'',
                cPwd:'',
                name:'',
            }
        },
        methods:{
            goback(){
                // 控制修改密码显示隐藏
                this.$emit('setdata',this.isShow);
            },
            markSure(){
                var reg=/^[1-9a-zA-Z]{1,}$/;
                var str=this.newPwd;
                if(reg.test(str)){
                    //this.$message('验证正确');
                    if(this.newPwd==this.cPwd){
                    this.updata();
                    this.$message('修改成功');
                    
                     this.goback();                    
                 }else{
                    this.$message('新密码两次输入不一致');
                    this.newPwd='';
                    this.cPwd='';
                }
                }else{
                    this.$message('密码不能为空');
                }                 
            },
            //修改请求
            updata(){
            var url="http://125.210.160.93:8080/SmEdu/pass/admi/update";
                if(this.name.length>0){
                    name=this.name;
                    console.log(name);
                    console.log(4444441);
                  this.$http.post(url,{name:name ,hspw:this.newPwd}).then((res)=>{
                    console.log(res);
                }).catch((err)=>{
                    console.log(err);
                    })
            
                }else{
                   
                  this.$http.post(url,{hspw:this.newPwd}).then((res)=>{
                 console.log(res);
            }).catch((err)=>{
                console.log(err);
                })
            
                }
                //  console.log(name);
                //  console.log(444444);
            }
        },
        create(){
           /* var url="http://125.210.160.93:8080/SmEdu/port/admi/login";
            this.$http.post(url,{hsid:this.hsid,hspw:this.hspw}).then((res)=>{
                    console.log(res);
                console.log(res.data);
                console.log(res.data.head);
                console.log(res.data.head.desc);
                 if(res.data.head.code==100){                 
                     this.open6();
                     setTimeout(()=>{this.$router.push({path:'/index'})},1000)
                 }else{
                     this.warnMsg=res.data.head.desc;
                     this.open7();
                     return
                 } 
            }).catch((err)=>{
                console.log(err);
            })*/
        }
    }
</script>
<style scope> 
    #AmentPortrait{
        height:100%;
        height:650px;    
    }
    #AmentPortrait .masklayer{
         height:650px;
    }
    #AmentPortrait .aportrait{
        position: relative;
        text-align: center;
        margin-left:5%;
        width:90%;
        height:40%;
        position: absolute;
        top:20%;
        /* border: 1px solid black; */
        background: #fff;
        border-radius: 15px;
    }
     #AmentPortrait h3{
         font-weight: 100;
         font-size: 20px;
     }
      #AmentPortrait input{
          width:70%;
          height:10%;
          margin:10px;
          border:0;
          border-top:1px solid black;  
          outline: none;
      }
     #AmentPortrait .aportrait img{
         width:40%;
         height:40%;
         border-radius: 50%;
         margin:10% 0;
     }
    #AmentPortrait .aportrait .btn{
       margin:0 10%;
    }
    #AmentPortrait h3{
        margin:5%;
    }
</style>
